import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Hi from '@/components/Hi'
import NewContent from '@/components/NewContent'
import router from '../../../londy-element/src/router'
// import Hi1 from '@/components/Hi1'
// import Hi2 from '@/components/Hi2'

Vue.use(Router)

export default new Router({
  // mode: 'histroy',
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld,
      meta: {title: '首页'},
      alias: '/vav'
    },
    {
      path: '/hi',
      name: 'hi',
      component: Hi,
      meta: {title: 'Hi'},
      alias: '/londy'
    },
    {
      path: '/NewContent/:newsId(\\d+)/:newTitle',
      name: 'NewContent',
      meta: {title: '新闻内容'},
      component: NewContent,
      beforeEnter: (to, from, next) => {
        console.log('我进入了新闻内容模板')
        console.log(to)
        console.log(from)
        next()
      }
    },
    {
      path: '/goback',
      redirect: '/'
    },
    {
      path: '/goNewContent/:newsId(\\d+)/:newTitle',
      redirect: '/NewContent/:newsId(\\d+)/:newTitle'
    }
  ]
})
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})
